#ifndef __MTASK__H__
#define __MTASK__H__
#define MTASK_CMD_PUSH      0x01
#define MTASK_CMD_POP       0x02
#define MTASK_TO_QHEAD      0x01
typedef struct MHEAD
{
    int cmd;
    int flag;
    int mtaskid;
    int qtaskid;
    int64_t data_id;
}MHEAD;
typedef struct _MTASK
{
    int fd;
    int mtaskid;
    int qtaskid;
    int mtotal;
    int qtotal;
    struct sockaddr_in rsa;
}MTASK;
/* set message task */
int mtask_set(MTASK *mtask, char *ip, int port, int mtaskid, int qtaskid);
/* connect to qtask 
 * -1 mtask is NULL
 * -2 socket() failed
 * -3 connect() failed
 * */
int mtask_connect(MTASK *mtask);
/* get new task 
 * -1 mtask is NULL
 * -2 mtask->fd <= 0 and mtask_connect failed
 * -3 write() failed
 * -4 read failed
 * */
int64_t mtask_commit(MTASK *mtask, int64_t data_id, int flag);
/* close message task */
void mtask_close(MTASK *mtask);
#endif
